Editing JavaScript

HTML mode has support for editing and coloring of JavaScript. To use this you have to set some flags via the menu Config -> Current mode -> Flags, which are not set by default. The following flags and variables concern JavaScript:

JavaScriptColoring - when set, key words and comments in JavaScript will be colored. The way the HTML tags are colored is also changed, because the old way does not work well together with JavaScript. For the HTML tags to be colored nicely, all their attributes must be quoted.

elecLBrace - when set, the left braces, {, will be electric like in C mode.

elecRBrace - when set, the right braces, }, will be electric like in C mode.

JavaScriptColor - the color of the key words in JavaScript, if JavaScriptColoring is set. Default is magenta.

stringColor - the color of text between quotes, if JavaScriptColoring is set. Default is green.

inclEventHandler - when set, the event handlers (onFocus, onSelect etc.) will appear in the attribute dialog. By default they will not do so. Set this flag when you are editing files with JavaScript.

If you do not have an American keyboard, you may have to set two key bindings to be able to use the electric left and right braces. For example, on my Swedish keyboard { is shift-opt-8 and } is shift-opt-9. To use the electric braces I have to bind these keys with

bind '8' electricLeft HTML
bind '9' electricRight HTML

This is put in HTML's preference file, via the menu Config -> Current mode -> Edit prefs. Change your key bindings similarly if needed.